﻿

using System.Management.Automation;

namespace ExcelPoSH
{
    // txtInput.Tag is set to an instance of this class

    // Dirty is set to true when txtInput.Text changes
    // indicating that the loaded script needs saving.

    // Path is the path to the PowerShell script
    // loaded into txtInput
    // If Path is null, the script has not been saved yet.

    class ScriptFileProps
    {
        private bool mDirty = false;
        private string mPath = null;

        public ScriptFileProps(bool dirty, string path)
        {
            Dirty = dirty;
            Path = path;
        }

        public bool Dirty
        {
            get
            {
                return mDirty;
            }
            set
            {
                mDirty = value;
            }
        }

        public string Path
        {
            get
            {
                return mPath;
            }
            set
            {
                mPath = value;
            }
        }
    }

    // PSVariable derived classes to make Excel VBA Glabals 
    // available to PowerShell (some of them)

    public class ActiveCell : PSVariable
    {
        public ActiveCell(string name) : base(name) { }
        
        public override object Value
        {
            get 
            { 
                return Globals.ThisAddIn.Application.ActiveCell; 
            }
        }
    }

    public class ActiveChart : PSVariable
    {
        public ActiveChart(string name) : base(name) { }

        public override object Value
        {
            get
            {
                return Globals.ThisAddIn.Application.ActiveChart;
            }
        }
    }

    public class ActivePrinter : PSVariable
    {
        public ActivePrinter(string name) : base(name) { }

        public override object Value
        {
            get
            {
                return Globals.ThisAddIn.Application.ActivePrinter;
            }
        }
    }

    public class ActiveSheet : PSVariable
    {
        public ActiveSheet(string name) : base(name) { }
        
        public override object Value
        {
            get 
            { 
                return Globals.ThisAddIn.Application.ActiveSheet; 
            }
        }
    }

    public class ActiveWindow : PSVariable
    {
        public ActiveWindow(string name) : base(name) { }

        public override object Value
        {
            get
            {
                return Globals.ThisAddIn.Application.ActiveWindow;
            }
        }
    }

    public class ActiveWorkbook : PSVariable
    {
        public ActiveWorkbook(string name) : base(name) { }

        public override object Value
        {
            get 
            { 
                return Globals.ThisAddIn.Application.ActiveWorkbook; 
            }
        }
    }

    public class Cells : PSVariable
    {
        public Cells(string name) : base(name) { }

        public override object Value
        {
            get 
            { 
                return Globals.ThisAddIn.Application.Cells; 
            }
        }
    }
}